package gaml.yaml;

import java.util.ArrayList;
import java.util.HashMap;


/**
 * map-type yaml node java implementation
 * @author shnireck_vi
 *
 */
public class MappingNode extends YamlNode {
	
	HashMap <YamlNode, YamlNode> children = new HashMap <YamlNode, YamlNode> ();
	
	public MappingNode (YamlNode parent) {
		this.parent = parent;
		if (null != parent) level = parent.getLevel () + 1;
	}

	@Override
	public YamlNode addChild (YamlNode value) { return this; }

	@Override
	public YamlNode addChild (YamlNode key, YamlNode val) {
		children.put (key, val);
		return this;
	}

	@Override
	public ArrayList <YamlNode> getSequenceChildren () { return new ArrayList <YamlNode> (); }

	@Override
	public HashMap <YamlNode, YamlNode> getMappingChildren () { return children; }

	@Override
	public String getValue () { return ""; }

	@Override
	public YamlNode setValue (String value) { return this; }

	@Override
	public YamlNode getChild (YamlNode key) { return children.get (key); }

	@Override
	public YamlNode getChild (int index) { return null; }

	@Override
	public boolean isEmpty () { return getMappingChildren ().isEmpty (); }
}